
//
//  JWUITabView.m
//  见闻新闻
//
//  Created by brother on 16/2/29.
//  Copyright © 2016年 JoanBoat. All rights reserved.
//

#import "JWUITabView.h"
#import "JWSideViewController.h"

@interface JWUITabView ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation JWUITabView

-(instancetype)initWithFrame:(CGRect)frame{
    self =[super initWithFrame:frame];
    //    设置代理和数据源
    self.delegate=self;
    self.dataSource=self;
    
    self.rowHeight=[UIScreen mainScreen].bounds.size.height/15;
    
    self.separatorStyle=NO;
      return  self;
}

//实现数据源方法
-(NSInteger)numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    if (indexPath.row==0) {
        cell.imageView.image=[UIImage imageNamed:@"sidebar_business"];
        cell.textLabel.text=@"我的收藏";
    }else if (indexPath.row==1){
        cell.imageView.image=[UIImage imageNamed:@"sidebar_purse"];
        cell.textLabel.text=@"要闻推送";
    }else if (indexPath.row==2){
        cell.imageView.image=[UIImage imageNamed:@"sidebar_decoration"];
        cell.textLabel.text=@"个性主题";
    }else if (indexPath.row==3){
        cell.imageView.image=[UIImage imageNamed:@"sidebar_favorit"];
        cell.textLabel.text=@"更多设置";
    }else{
        cell.imageView.image=[UIImage imageNamed:@"sidebar_file"];
        cell.textLabel.text=@"清除缓存";
    }

    self.backgroundColor = [UIColor colorWithRed:13/255.0 green:184/255.0 blue:246/255.0 alpha:1];
    cell.backgroundColor = [UIColor colorWithRed:13/255.0 green:184/255.0 blue:246/255.0 alpha:1];
    cell.textLabel.textColor=[UIColor whiteColor];
    //    点击cell时没有点击效果
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
//       cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2);
    return cell;
    
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    

    NSString *row = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
    
    NSDictionary *dict = [NSDictionary dictionaryWithObject:row forKey:@"A"];
    
    NSLog(@"%@",dict[@"A"]);
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"TableViewCellClick" object:nil userInfo:dict];

   
  }

@end
